#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

bool isPrime(long long n)
{
    if(n < 2)
    {
        fprintf(stderr, "I don't know\n");
        exit(1);
    }
    if(n == 2)
        return true;

    double arg = sqrt(n);
    for (int i = 2; i <= arg; ++i)
    {
        if(n % i == 0)
            return false;        
    }
    return true;
}

long long* generatePrimes(int n)
{
    long long* arr = (long long*)malloc(n * sizeof(long long));
    long long num = 2;
    int i = 0;

    while(i < n)
    {
        if(isPrime(num))
        {
            arr[i] = num;
            i++;
        }
        num++; 
    }         

    return arr;    
}

int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        fprintf(stderr, "./generatePrimes number\n");
        exit(1);
    }
    else
    {
        int n = 10;
        sscanf(argv[1],"%d",&n);
        long long* arr = generatePrimes(n);

        for(int i = 0; i < n; ++i)
            printf("%lld ", arr[i]);
        printf("\n");

        free(arr);
        return 0;
    }

}

